package com.app.controller;

import com.app.model.AdminUserModel;
import com.app.model.UserModel;
import com.app.service.PersonalInformationService;
import com.app.service.UserService;
import com.app.util.Result;
import com.app.util.TokenUtils;
import com.app.util.WxQrCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RequestMapping("/personalInformation")
@RestController
public class PersonalInformationController {

    @Autowired
    private PersonalInformationService personalInformationService;
    @Autowired
    private UserService userService;


    /**
     *小程序————新增前查询用户填写过的个人信息详情
     */
    @GetMapping("/getOneByUid")
    public Result getOneByUid(HttpServletRequest request)  {
        String token = request.getHeader("token");
        if (token == null) {
            return Result.error(405, "token不存在");
        }
        String mobile = TokenUtils.verify(token);
        UserModel user = userService.getUserByMobile(mobile);
        if (user == null) {
            return Result.error(405, "用户不存在");
        }
        return personalInformationService.getOneByUid(user);
    }









}
